package com.summer.controller;

import com.summer.pojo.JDGood;
import com.summer.service.ContentService;
import com.summer.utils.HtmlParseUtil;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;
import java.util.Map;
//请求编写
@RestController
public class SearchController {

    @Autowired
    private ContentService contentService;


    @RequestMapping("/search/{keyword}")
    public List<JDGood> keywordSearch(@PathVariable("keyword") String keyword) throws Exception {
        return new HtmlParseUtil().JDSearch(keyword);
    }

    @RequestMapping("/parse/{keyword}")
    public Boolean parseContent(@PathVariable("keyword") String keyword) throws Exception {
        System.out.println(keyword);
        return contentService.parseContent(keyword);
    }

    @RequestMapping("/search/{keyword}/{pageNo}/{pageSize}")
    public List<Map<String,Object>> keywordSearch(@PathVariable("keyword") String keyword, @PathVariable int pageNo, @PathVariable int pageSize) throws Exception {
        return contentService.searchPage(keyword,pageNo,pageSize);
    }

}
